package com.sjb.sixteen_journey_backend.controller;


import com.sjb.sixteen_journey_backend.common.R;
import com.sjb.sixteen_journey_backend.entity.OthersTicket;
import com.sjb.sixteen_journey_backend.service.IOthersTicketService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * 其他晒单表
 *
 * @author jcz
 * @since 2024-07-13
 */
@RestController
@RequestMapping("/others-ticket")
public class OthersTicketController {
    @Autowired
    private IOthersTicketService othersTicketService;
    /**
     * 增加其他晒单表
     * @param othersTicket
     * @return
     */
    @PostMapping("/addOthersTicket")
    public R addOthersTicket(@RequestBody @Valid OthersTicket othersTicket) {
        return othersTicketService.addOthersTicket(othersTicket);
    }
//    @PostMapping("/addOthersTicket")
//    public R addOthersTicket(@RequestBody OthersTicket othersTicket, @RequestParam("image") ArrayList<MultipartFile> images) {
//        return othersTicketService.addOthersTicket(othersTicket, images);
//    }

    /**
     * 删除用户的一篇其他晒单
     * @param id
     * @return
     */
    @DeleteMapping("/deleteOthersTicketById/{id}")
    public R deleteOthersTicketById(@PathVariable("id") Integer id ) {
        return othersTicketService.deleteOthersTicketById(id);
    }


    /**
     * 获取所有其他晒单
     * @return
     */
    @GetMapping("showAllOthersTicket")
    public R<List<OthersTicket>> showAllOthersTicket(){
        return othersTicketService.showAllOthersTicket();
    }

    /**
     * 根据晒单id查其他晒单
     * @param id 晒单id
     * @return
     */
    @GetMapping("showAllOthersTicketById{id}")
    public R showAllOthersTicketById(@PathVariable("id") Integer id){
        return othersTicketService.showAllOthersTicketById(id,true);
    }


    /**
     * 根据用户id获取所有其他晒单
     * @return
     */
    @GetMapping("showAllOthersTicketByUserId")
    public R<List<OthersTicket>> showAllOthersTicketByUserId(){
        return othersTicketService.showAllOthersTicketByUserId();
    }

}
